package lwh.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import lwh.utils.DBOpenHelper;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

public class TimeStampService {
	private DBOpenHelper dbOpenHelper;
	public TimeStampService(Context context) {
		this.dbOpenHelper = new DBOpenHelper(context);
	}
	public String getMobineTableTime(String table_name){
		SQLiteDatabase db = dbOpenHelper.getReadableDatabase();
		Cursor cursor = db.rawQuery("select * from sys_tab_timestamps where tab_name=?",
				new String[]{table_name});
		String resultTime="";
		if(cursor.moveToNext()){
			resultTime=cursor.getString(cursor.getColumnIndex("tab_timestamp"));
		}
		cursor.close();
		db.close();
		return resultTime;
	}
	
	public boolean updateMobineTableTime(String tab_name,String tab_time){
		SQLiteDatabase db = dbOpenHelper.getReadableDatabase();
		db.beginTransaction();
		db.execSQL("update sys_tab_timestamps set tab_timestamp=? where tab_name=?", new Object[]{tab_time,tab_name});
		db.setTransactionSuccessful();
		db.endTransaction();
		db.close();
		return false;
	}
	public void closeDBHelper(){
		dbOpenHelper.close();
	}
}
